#include "vector4.h"
#include "vector3.h"
#include "color.h"
#include "matrix.h"
#include <math.h>
#include <sstream>

std::string vector4::ToString() const
{
	std::stringstream _tmp;
	_tmp << "[" << x;
	_tmp << ", " << y;
	_tmp << ", " << z;
	_tmp << ", " << w << "]";
	return _tmp.str();
}
vector4::vector4(void)
{
	this->x = 0.0f;
	this->y = 0.0f;
	this->z = 0.0f;
	this->w = 0.0f;
}
vector4::vector4(const vector3 &a, int w)
{
	this->x = a.x;
	this->y = a.y;
	this->z = a.z;
	this->w = (float)w;
}
vector4::vector4(const vector3 &a, float w)
{
	this->x = a.x;
	this->y = a.y;
	this->z = a.z;
	this->w = w;
}
vector4::vector4(const vector4 &a)
{
	this->x = a.x;
	this->y = a.y;
	this->z = a.z;
	this->w = a.w;
}
vector4::vector4(const color &colorA)
{
	this->x = colorA.r/255.0f;
	this->y = colorA.g/255.0f;
	this->z = colorA.b/255.0f;
	this->w = colorA.a/255.0f;
}

vector4::vector4(int x, int y, int z, int w)
{
	this->x = (float)(x);
	this->y = (float)(y);
	this->z = (float)(z);
	this->w = (float)(w);
}
vector4::vector4(uint x, uint y, uint z, uint w)
{
	this->x = (float)(x);
	this->y = (float)(y);
	this->z = (float)(z);
	this->w = (float)(w);
}
vector4::vector4(float x, float y, float z, float w)
{
	this->x = x;
	this->y = y;
	this->z = z;
	this->w = w;
}
vector4::~vector4(void)
{
}
float vector4::Length()
{
	return sqrt(pow(x,2) + pow(y,2) + pow(z,2) + pow(w,2));
}
vector4 vector4::Normalize()
{
	float mag = Length();
	return vector4(x/mag, y/mag , z/mag, w/mag);
}
vector4 vector4::NormalizeW()
{
	return vector4(x/w, y/w, z/w, 1.0f);
}
vector4 vector4::Negate()
{
	return vector4(-x, -y, -z, -w);
}
vector4 vector4::operator*(float a)
{
	return vector4(x * a, y * a, z * a, w * a);
}
vector4 vector4::operator/(float a)
{
	return vector4(x / a, y / a, z / a, w / a);
}
vector4 vector4::operator+(const vector4 &b)
{
	return vector4(x + b.x, y + b.y, z + b.z, w + b.w);
}
vector4 vector4::operator-(const vector4 &b)
{
	return vector4(x - b.x, y - b.y, z - b.z, w - b.w);
}